package com.example.mapper.tribune;


import com.example.model.entity.tribune.Post;
import com.example.model.entity.tribune.PostSuccess;
import com.example.model.vo.PostVO;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 操作post相关数据接口
*/
public interface PostMapper {

    /**
      * 新增
    */
    int insert(Post post);

    /**
      * 删除
    */
    int deleteById(Integer id);

    /**
      * 修改
    */
    int updateById(Post post);

    /**
      * 根据ID查询
    */
    PostVO selectById(Integer id);

    /**
      * 查询所有
    */
    List<Post> selectAll(Post post);
    @Select("select * from post where typeId = #{typeId} and status='审核通过'")
    List<Post> selectByTypeId(Integer typeId);

    PostSuccess selectSuccessById(Integer roleId);

    List<Post> selectFrontPost(Integer typeId);

    List<Post> selectRandomPost(Post post);

    List<Post> selectTopPost(Post post);

    @Update("update post set lookNum = post.lookNum + 1 where id = #{id}")
    void updateCount(Integer id);
}
